package com.iflytek.aisol.audit.iflytek.strategy.manage.constant;

import com.fasterxml.jackson.annotation.JsonValue;
import com.iflytek.aisol.audit.iflytek.strategy.manage.handler.ChannelHandler;
import com.iflytek.aisol.audit.iflytek.strategy.manage.handler.impl.CommonChannelHandler;
import com.iflytek.aisol.audit.iflytek.strategy.manage.handler.impl.AggDefaultChannelHandler;

import java.util.Arrays;

public enum ChannelType {
    IVE("ive",CommonChannelHandler.class),
    RIT("rit", CommonChannelHandler.class),
    LLM_AUDIT_RAG("llmAudit_RAG",CommonChannelHandler.class),
    LLM_AUDIT("llmAudit",CommonChannelHandler.class),
    VDT("vdt",CommonChannelHandler.class),
    AGG_DEFAULT("agg_default", AggDefaultChannelHandler.class);

    private final String type;
    private final Class<? extends ChannelHandler> handlerClass;

    ChannelType(String type, Class<? extends ChannelHandler> handlerClass) {
        this.type = type;
        this.handlerClass = handlerClass;
    }

    @JsonValue
    public String getType() {
        return type;
    }

    public Class<? extends ChannelHandler> getHandlerClass() {
        return handlerClass;
    }

    public static ChannelType fromType(String type) {
        return Arrays.stream(values())
                .filter(e -> e.type.equalsIgnoreCase(type))
                .findFirst()
                .orElseThrow(() -> new IllegalArgumentException("Invalid channel type: " + type));
    }
}
